#ifndef _SYS_ERR_H_
#define _SYS_ERR_H_

#include "FanObj.h"
#include "SysTypes.h"

#define ERR_VTABLE(self)   ((ErrVTable*)((FanObj*)self)->vtable)


extern Type*    Err_classType;
extern VTable*  Err_classVTable;


/* [sys::Err] Attributes */
struct Err
{
  FanObj        super;
  Str*          msg;
  Err*          cause;
};


/* [sys::Err] Virtual-table */
typedef struct ErrVTable
{
  FanObjVTable  super;
} ErrVTable;


/* [sys::Err] Methods and fields */
void            Err_make_0(Err* self);
void            Err_make_1(Err* self, Str* msg);
void            Err_make(Err* self, Str* msg, Err* cause);
Str*            Err_toStr(Obj self);
Str*            Err_msg(Err* self);
Err*            Err_cause(Err* self);
Err*            Err_trace_0(Err* self);
Err*            Err_trace_1(Err* self, OutStream* out);
Err*            Err_trace(Err* self, OutStream* out, Map* options);
Str*            Err_traceToStr(Err* self);


/* [sys::Err] Extra methods */
Err*          Err_new(Str* msg, Err* cause);
Err*          Err_newWithFormattedMsg(const char* msgFormat, ...);


/* [sys::Err] Type-system functions */
Type*           Err_initType(void);
VTable*         Err_initVTable(void);
void            Err_initStatic(void);


#endif
